import time

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By

# from selenium.webdriver.firefox.options import Options

# 创建 Chrome 选项
options = Options()

# 设置 Chrome 选项，例如无头模式
# chrome_options.add_argument('--headless')

# 定义所需的浏览器功能

driver = webdriver.Remote(
    command_executor='http://192.168.68.135:4444/wd/hub',
    options=options
    # options=chrome_options
)

driver.maximize_window()
driver.get("https://www.baidu.com")
driver.find_element(By.ID, "kw").send_keys("python")
driver.find_element(By.CSS_SELECTOR, "input#su").click()
time.sleep(3)
rs = driver.find_elements(By.CSS_SELECTOR, "div.opr-toplist1-table_544Ty > div > div")
for i in rs:
    i_title = i.find_element(By.CSS_SELECTOR, "a")
    print(i_title.get_attribute("title"))
